package com.xinghou.platform.dao.main.impl;
import java.sql.ResultSet;
import java.sql.SQLException;

import javax.annotation.Resource;

import org.springframework.dao.DataAccessException;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.stereotype.Service;

import com.xinghou.platform.dao.bases.JdbcTemplate;
import com.xinghou.platform.dao.bases.database.CustomerContextHolder;
import com.xinghou.platform.dao.main.ReportSharedCardDAO;
import com.xinghou.platform.model.main.ReportSharedCard;

/**
 * @author liuwei.wen
 *
 */
@Service
public class ReportSharedCardDAOImpl  {/*

	@Resource
	private JdbcTemplate jdbcTemplate;

	@Override
	public ReportSharedCard getReportSharedCardById(Integer Id) throws DataAccessException {
		CustomerContextHolder.setCustomerType(CustomerContextHolder.DATA_SOURCE_READ);
		String sql="SELECT Id,User_id,Card_id,Reason_id,Description,STATUS,Create_time FROM  report_shared_card where Id=?";
		ReportSharedCard reportSharedCard = jdbcTemplate.queryForObject(sql, new Object[] {Id}, new ReportSharedCardMapper());
		CustomerContextHolder.clearCustomerType();
		return reportSharedCard;
	}

	@Override
	public int updateReportSharedCard(ReportSharedCard reportSharedCard) throws DataAccessException {
		StringBuffer strSQL = new StringBuffer("UPDATE report_shared_card SET User_id = ? ,Card_id = ?,Reason_id =?,Description = ? ,STATUS = ?,Create_time = ? WHERE Id=?");					
		Object[] params = {reportSharedCard.getUserId(),reportSharedCard.getCardId(),reportSharedCard.getReasonId(),reportSharedCard.getDescription(),reportSharedCard.getStatus(),reportSharedCard.getCreateTime(),reportSharedCard.getId()};
		CustomerContextHolder.setCustomerType(CustomerContextHolder.DATA_SOURCE_WRITE);
		int ret = jdbcTemplate.update(strSQL.toString(),params);
		CustomerContextHolder.clearCustomerType();
		return ret;
	}

	@Override
	public int saveReportSharedCard(ReportSharedCard reportSharedCard) throws DataAccessException {
		StringBuffer strSQL = new StringBuffer("INSERT INTO report_shared_card (User_id,Card_id,Reason_id,Description,STATUS,Create_time) VALUES(?,?,?,?,?,?);");			
		Object[] params = {reportSharedCard.getUserId(),reportSharedCard.getCardId(),reportSharedCard.getReasonId(),reportSharedCard.getDescription(),reportSharedCard.getStatus(),reportSharedCard.getCreateTime()};
		CustomerContextHolder.setCustomerType(CustomerContextHolder.DATA_SOURCE_WRITE);
		int ret =jdbcTemplate.save(strSQL.toString(),params);
		CustomerContextHolder.clearCustomerType();
		return ret;
	}
	
	private static final class ReportSharedCardMapper implements RowMapper<ReportSharedCard> {
		public ReportSharedCard mapRow(ResultSet rs, int rowNum) throws SQLException {
			ReportSharedCard reportSharedCard = new ReportSharedCard();
			reportSharedCard.setCardId(rs.getInt("Card_id"));
			reportSharedCard.setCreateTime(rs.getDate("Create_time"));
			reportSharedCard.setDescription(rs.getString("Description"));
			reportSharedCard.setId(rs.getInt("Id"));
			reportSharedCard.setReasonId(rs.getShort("Reason_id"));
			reportSharedCard.setStatus(rs.getShort("STATUS"));
			reportSharedCard.setUserId(rs.getInt("User_id"));
			return reportSharedCard;
		}
	}*/

}
